use std::path::{PathBuf, Path};
use core::{Package, Workspace};
-use util::{Config, FileLock, CargoResult, Filesystem};
+use util::{Config, FileLock, CargoResult, Filesystem, human};
use util::hex::short_hash;
use super::Unit;
// the target triple as a Path and then just use the file stem as the
// component for the directory name.
if let Some(triple) = triple {
- path.push(Path::new(triple).file_stem().unwrap());
+ path.push(try!(Path::new(triple).file_stem()
+ .ok_or(human(format!("target was empty")))));
}
path.push(dest);
Layout::at(ws.config(), path)
.with_stderr("[..] foo v0.0.1 ([..])\n\
[FINISHED] debug [unoptimized + debuginfo] target(s) in [..]\n"));
}
+
+#[test]
+fn cargo_build_empty_target() {
+ let p = project("foo")
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .file("src/main.rs", "fn main() {}");
+ p.build();
+
+ assert_that(p.cargo_process("build").arg("--target").arg(""),
+ execs().with_status(101)
+ .with_stderr_contains("[..] target was empty"));
+}